The Anatomy of Compound Types
C++ compound types are defined by combining a base type with a type modifier. While both references and pointers provide indirection, they are philosophically distinct. A Reference (&) is a permanent alias—a nickname for an existing object. Once bound, it cannot be reseated. Conversely, a Pointer (*) is an independent object in memory that stores a hexadecimal address. It can be redirected to different objects or set to nullptr.
Visualizing the Memory
In the code int *p1, p2;, only p1 is a pointer; p2 is a plain integer. To make both pointers, use int *p1, *p2;. This emphasizes that the modifier belongs to the individual declarator, not the base type.
TERMINAL
bash — 80x24
> Ready. Click "Run" to execute.
>